order_by('-pk') replace of order_by('-created_at')

Brightcells 9 ans auparavant
Parent
Commettre
0786f22bad
4 fichiers modifiés avec 9 ajouts et 9 suppressions
  1. 3 3
      account/views.py
  2. 3 3
      group/views.py
  3. 2 2
      message/views.py
  4. 1 1
      photo/views.py

+ 3 - 3
account/views.py

@@ -222,7 +222,7 @@ class UserViewSet(viewsets.ModelViewSet):
222 222
     """
223 223
     API endpoint that allows users to be viewed or edited.
224 224
     """
225
-    queryset = User.objects.all().order_by('-date_joined')
225
+    queryset = User.objects.all().order_by('-pk')
226 226
     serializer_class = UserSerializer
227 227
 
228 228
 
@@ -235,10 +235,10 @@ class GroupViewSet(viewsets.ModelViewSet):
235 235
 
236 236
 
237 237
 class LensmanInfoViewSet(viewsets.ModelViewSet):
238
-    queryset = LensmanInfo.objects.all().order_by('-created_at')
238
+    queryset = LensmanInfo.objects.all().order_by('-pk')
239 239
     serializer_class = LensmanInfoSerializer
240 240
 
241 241
 
242 242
 class UserInfoViewSet(viewsets.ModelViewSet):
243
-    queryset = UserInfo.objects.all().order_by('-created_at')
243
+    queryset = UserInfo.objects.all().order_by('-pk')
244 244
     serializer_class = UserInfoSerializer

+ 3 - 3
group/views.py

@@ -768,15 +768,15 @@ def thumbup_cancel_api(request):
768 768
 
769 769
 
770 770
 class GroupInfoViewSet(viewsets.ModelViewSet):
771
-    queryset = GroupInfo.objects.all().order_by('-created_at')
771
+    queryset = GroupInfo.objects.all().order_by('-pk')
772 772
     serializer_class = GroupInfoSerializer
773 773
 
774 774
 
775 775
 class GroupUserInfoViewSet(viewsets.ModelViewSet):
776
-    queryset = GroupUserInfo.objects.all().order_by('-created_at')
776
+    queryset = GroupUserInfo.objects.all().order_by('-pk')
777 777
     serializer_class = GroupUserInfoSerializer
778 778
 
779 779
 
780 780
 class GroupPhotoInfoViewSet(viewsets.ModelViewSet):
781
-    queryset = GroupPhotoInfo.objects.all().order_by('-created_at')
781
+    queryset = GroupPhotoInfo.objects.all().order_by('-pk')
782 782
     serializer_class = GroupPhotoInfoSerializer

+ 2 - 2
message/views.py

@@ -19,7 +19,7 @@ def message_list_api(request):
19 19
             to_uid=user_id,
20 20
             msg_type=message['msg_type'],
21 21
         ).order_by(
22
-            '-updated_at'
22
+            '-pk'
23 23
         )[:settings.MESSAGE_NUM_PER_PAGE]
24 24
         type_messages = [msg.msg_info for msg in type_messages]
25 25
         message['msg_list'] = type_messages
@@ -43,7 +43,7 @@ def message_type_list_api(request, msg_type):
43 43
         to_uid=user_id,
44 44
         msg_type=msg_type,
45 45
     ).order_by(
46
-        '-updated_at'
46
+        '-pk'
47 47
     )
48 48
     type_messages, left = pagination(type_messages, page, num)
49 49
     type_messages = [msg.msg_info for msg in type_messages]

+ 1 - 1
photo/views.py

@@ -203,5 +203,5 @@ def photo_raw(request, photo):
203 203
 
204 204
 
205 205
 class PhotoInfoViewSet(viewsets.ModelViewSet):
206
-    queryset = PhotosInfo.objects.all().order_by('-created_at')
206
+    queryset = PhotosInfo.objects.all().order_by('-pk')
207 207
     serializer_class = PhotosInfoSerializer